<?php
/**
 * In this File the class '\UF\RX' is defined.
 *
 * @category   UniKap-Framework
 * @package    Core
 * @subpackage Helpers
 * @author     Ulf -UniKado- Kadner <ulfikado@gmail.com>
 * @since      2014-03-29 16:17
 * @version    0.1
 */

namespace UF
{

    /**
     * Diese stellt Konstanten bereit, die regulaere Ausdruecke definieren,
     * welche zum pruefen unterschiedlicher Elemente genutzt werden koennen.
     *
     * Von dieser Klasse kann keine Instanz erstellt werden!
     *
     * @since  v0.1
     */
    class RX
    {

        # <editor-fold defaultstate="collapsed" desc="- - - -   C O N S T A N T S   - - - - - - - - - - - - - - - - - - - - - - - - - -">

        /**
         * This regular expression can be used, to check, if a string exclusive contains hexadecimal characters.
         * (0-9 a-f A-F)
         *
         * @since  v0.1
         */
        const HEX_RANGE = '~^[a-fA-F0-9]+$~';

        /**
         * This regular expression can be used, to check, if a string contains a valid hexadecimal value. It means
         * all characters must use the rang (0-9 a-f A-F) and the string length must be 2 or a multiple of it.
         *
         * @since  v0.1
         */
        const HEX_VALUE = '~^([a-fA-F0-9]{2})+$~';

        /**
         * This regular expression can be used, to check, if a string can be used as a mailaddress. But remember its
         * only a simple check that does not cover some special cases. E-Mail address checking for RFC conforming
         * format is very complex. But for most use cases this check is OK.
         *
         * @todo   At this time, i dont have think about the new domains, using some unicode characters. Maybe the
         *         regex is overaged and must be changed/corrected to handle this cases. I will check it in later
         *         framework versions.
         * @since  v0.1
         */
        const EMAIL = '~^[A-Za-z_][A-Za-z0-9_.-]*@([A-Za-z][A-Za-z0-9_.-]+)$~';

        /**
         * This regular expression can be used, to check, if a string contains some random typed characters.
         *
         * @since  v0.1
         * @todo   The Name 'RANDOM_CHARSET' is realy bad. I have to change it, if project is nearly complete.
         */
        const RANDOM_CHARSET = '~\b(fsd|xvc|dfg|sfd|dgf|fgh|gjh|hkj|sdf|yxc|xcv|cvb|vbn|dyfg|fdsa|etrz)~i';

        /**
         * Defines a list with some buzzwords, often used in some spam comments or mails. Its a mix of german and
         * english words (fragments)
         *
         * @since  v0.1
         */
        const BADWORDS = '~\b(dumm|fick|arsch|nazi|hoden|votze|fotze|viagra|anal|dollar|valium|sex|pussy|hitler|fuck|casino|money|penis|cash|money|pharma|rabat|health|mall|adult|dollar|buss?ines|\$\d+|gina|winner|sweepstakes|lottery|payment|medicine|hospital|jewel|shopping|jude|himmler|bonus|islam)~i';

        /**
         * Often SPAMs contains some words in Formats like <code>V I A G R A</code> or something else. THis regexp
         * let you identify such formats.
         *
         * @since  v0.1
         */
        const INCONSISTENT_TEXT = '~[\pL\pN]([ \t#._-]+[\pL\pN]){3,}~';

        /**
         * Finds all HTTP, SSL and FTP URLs inside a string. Matches are 1=protocol, 2=domain, 3=path+
         *
         * @since  v0.1
         */
        const URL_FIND = '~(https?|ftp)://([a-z0-9_.-]+)(/[a-z0-9_./+%?&#]+)?~i';

        /**
         * Checks if a string contains some url encoded contents. Can be used to check e.g. web page comments.
         * It can be a indicator for a spam request!
         *
         * @since  v0.1
         */
        const URL_ENCODING = '~%[\dA-Fa-f]{2}~';

        /**
         * This regular expression can be used, to check, if a string contains some HTML entities.
         *
         * @since  v0.1
         */
        const HTML_ENTITY = '~&([A-Za-z]{2,7}|#[\dA-Fa-f]{2,4});~';

        /**
         * This regular expression can be used, to check, if a string is a woldwide usable telephone number. It does
         * not check if the number is callable. That a regex can not do in this case. Matches are 1=Country prefix,
         * 3=Region prefix, 4=The number
         *
         * @since  v0.1
         */
        const PHONE_NUMBER_FULL = '~^((\+|00)\d{2,4})[ -/]([1-9]\d{2,6})[ -/]([1-9]\d{2,7}([ -/]\d{1,4})?)$~';

        /**
         * This regular expression can be used, to check, if a string is a inside a country usable telephone number.
         * It does not check if the Number is callable. :-) Matches are  1=Region prefix, 3=The number
         *
         * @since  v0.1
         */
        const PHONE_NUMBER = '~^(0([1-9]\d{1,6}))[ -/]([1-9]\d{2,7}([ -/]\d{1,4})?)$~';

        # </editor-fold>

        # <editor-fold defaultstate="collapsed" desc="- - - >   H I D D E N   C O N S T R U C T O R   - - - - - - - - - - - - - - - - -">

        /**
         * @since  v0.1
         */
        private function __construct() { }

        # </editor-fold>

    }

}

